home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.7 KB | 234 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRRcShp.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWGRGLOB_H
- #include "FWGrGlob.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef FWRASTER_H
- #include "FWRaster.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_RoundRectShape
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CRoundRectShape, FW_CBoundedShape)
-
- FW_REGISTER_ARCHIVABLE_CLASS(FW_LRoundRectShape, FW_CRoundRectShape, FW_CRoundRectShape::Read, FW_CShape::Write)
-
- //========================================================================================
- // class FW_CRoundRectShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(const FW_CRoundRectShape& other) :
- FW_CBoundedShape(other),
- fOvalSize(other.fOvalSize)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(const FW_CRect& rect,
- const FW_CPoint& ovalSize,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style) :
- FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont),
- fOvalSize(ovalSize)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::FW_CRoundRectShape(FW_CReadableStream& archive) :
- FW_CBoundedShape(archive)
- {
- archive >> fOvalSize;
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::~FW_CRoundRectShape
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape::~FW_CRoundRectShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CRoundRectShape& FW_CRoundRectShape::operator=(const FW_CRoundRectShape& other)
- {
- if (this != &other)
- {
- FW_CBoundedShape::operator=(other);
- fOvalSize = other.fOvalSize;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::Render(FW_CGraphicContext& gc) const
- {
- gc.GetRasterizer()->RenderRoundRect(gc,
- fRect, fOvalSize,
- GetRenderVerb(),
- fInk,
- fStyle);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::RenderRoundRect
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::RenderRoundRect(FW_CGraphicContext& gc,
- const FW_CRect& rect,
- const FW_CPoint& ovalSize,
- FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style)
- {
- gc.GetRasterizer()->RenderRoundRect(gc,
- rect, ovalSize,
- renderVerb,
- ink,
- style);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::HitTest
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CRoundRectShape::HitTest(FW_CGraphicContext& gc,
- const FW_CPoint& test,
- FW_CFixed tolerance) const
- {
- FW_UNUSED(gc);
-
- if(fRenderVerb == FW_kNoRendering)
- return FALSE;
-
- FW_CRect bounds(fRect);
- bounds.Inset(-tolerance, -tolerance);
-
- if(::FW_PtInRoundRect(bounds, fOvalSize, test))
- {
- if (fRenderVerb == FW_kFrame)
- {
- FW_CFixed inset = tolerance + GetPenSize();
- bounds = fRect;
- bounds.Inset(inset, inset);
- return !::FW_PtInRoundRect(bounds, fOvalSize, test);
- }
-
- return TRUE;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CRoundRectShape::Copy() const
- {
- return FW_NEW(FW_CRoundRectShape, (*this));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::GetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::GetGeometry(FW_CRect& rect, FW_CPoint& ovalSize) const
- {
- ovalSize = fOvalSize;
- rect = fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::SetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::SetGeometry(const FW_CRect& rect, const FW_CPoint& ovalSize)
- {
- fOvalSize = ovalSize;
- fRect = rect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CRoundRectShape::Flatten(FW_CWritableStream& archive) const
- {
- FW_CBoundedShape::Flatten(archive);
- archive << fOvalSize;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CRoundRectShape::Read
- //----------------------------------------------------------------------------------------
-
- void* FW_CRoundRectShape::Read(FW_CReadableStream& archive)
- {
- return FW_NEW(FW_CRoundRectShape, (archive));
- }
-
-